﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tools.Common.ServiceLocator;
using Web.App.Infrastructure.ApplicationMessages.Contracts;
using Webshop20.Domain.Common;
using Webshop20.Domain.Customers.Core;
using Webshop20.Domain.Customers.Factories.Contracts;
using Tools.Domain.Specifications.Constraints;
using Webshop20.Domain.Common.Exceptions;

namespace Webshop20.Factories.Implementation
{
    public class CustomerFactory : ICustomerFactory 
    {
        private IServiceLocator serviceLocator;

        public CustomerFactory(IServiceLocator serviceLocator)
        {
            this.serviceLocator = serviceLocator;
        }
        
        public Customer Create(string eMail, string firstName, string lastName)
        {
            var customerConstraintSet = serviceLocator.Resolve<IConstraintSet<Customer>>(typeof(NewCustomerRegistration).Name);
            Customer newCustomer = new Customer();


            newCustomer.SetCustomerData(firstName, lastName, eMail, string.Empty, string.Empty, string.Empty,
                                            string.Empty, customerConstraintSet);


            return newCustomer;
        }
   
    }
}
